{extend name='Common/index' /}
{block name='content'}
<section class="content">
  <div class="box box-default">
    <div class="box-header with-border">
      <h3 class="box-title">{$info?'修改':'新增'}用户组</h3>
    </div>
    <div class="box-body">
      <div class="form">
        <div class="form-group">
          <label for="name" class="col-sm-2 control-label">组名</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="name" name="name" placeholder="请输入用户名" value="{$info?$info['name']:''}" autocomplete="off">
            <input type="hidden"  name="id" value="{$info?$info['id']:''}">
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <button type="button" class="btn btn-primary sub">提交</button>
            <a href="javascript:history.go(-1);" class="btn btn-default">返回</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>
{/block}
{block name='js'}
<script src="__STATIC__/dist/js/formBasic.js"></script>
<script>
$('.sub').click(function(){
  let names = document.querySelectorAll('.form-group > div > [name]'),
      vals = {};
  names = [].slice.call(names);
  names.map((e)=>{
    vals[e.name] = e.value;
  });
  ajax('{:url("admin/User/addgroupAuth")}',vals,'post').then(e=>{
    if(e.status === 200){
      alert(e.msg);
      location.href="{:url('admin/User/group')}";
    } else {
      alert(e.msg);
    }
  });
});
</script>
{/block}
 